package org.learn.spring5.dao.impl;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

//创建代理对象调用的程序代码
public class MyInvocationHandler implements InvocationHandler {
    private Object object;
    //有参构造传递
    public MyInvocationHandler(Object object){
        this.object = object;
    }

    //增强的逻辑
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("方法之前处理");

        //被增强的方法执行
        Object invoke = method.invoke(object,args);

        System.out.println("方法之后处理");


        return invoke;
    }
}
